<!DOCTYPE html>

<html>
<head>
  <title>routes.coffee</title>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
  <link rel="stylesheet" media="all" href="docco.css" />
</head>
<body>
  <div id="container">
    <div id="background"></div>
    
      <ul id="jump_to">
        <li>
          <a class="large" href="javascript:void(0);">Jump To &hellip;</a>
          <a class="small" href="javascript:void(0);">+</a>
          <div id="jump_wrapper">
          <div id="jump_page">
            
              
              <a class="source" href="admin.html">
                admin.coffee
              </a>
            
              
              <a class="source" href="api.auditData.html">
                api.auditData.coffee
              </a>
            
              
              <a class="source" href="api.auditEvent.html">
                api.auditEvent.coffee
              </a>
            
              
              <a class="source" href="api.html">
                api.coffee
              </a>
            
              
              <a class="source" href="api.entity.html">
                api.entity.coffee
              </a>
            
              
              <a class="source" href="api.map.html">
                api.map.coffee
              </a>
            
              
              <a class="source" href="api.server.html">
                api.server.coffee
              </a>
            
              
              <a class="source" href="api.variable.html">
                api.variable.coffee
              </a>
            
              
              <a class="source" href="api.view.html">
                api.view.coffee
              </a>
            
              
              <a class="source" href="app.html">
                app.coffee
              </a>
            
              
              <a class="source" href="app.instance.html">
                app.instance.coffee
              </a>
            
              
              <a class="source" href="data.html">
                data.coffee
              </a>
            
              
              <a class="source" href="dataUtil.html">
                dataUtil.coffee
              </a>
            
              
              <a class="source" href="messages.html">
                messages.coffee
              </a>
            
              
              <a class="source" href="auditData.html">
                auditData.coffee
              </a>
            
              
              <a class="source" href="auditEvent.html">
                auditEvent.coffee
              </a>
            
              
              <a class="source" href="base.html">
                base.coffee
              </a>
            
              
              <a class="source" href="entityDefinition.html">
                entityDefinition.coffee
              </a>
            
              
              <a class="source" href="entityObject.html">
                entityObject.coffee
              </a>
            
              
              <a class="source" href="eventAction.html">
                eventAction.coffee
              </a>
            
              
              <a class="source" href="eventRule.html">
                eventRule.coffee
              </a>
            
              
              <a class="source" href="link.html">
                link.coffee
              </a>
            
              
              <a class="source" href="map.html">
                map.coffee
              </a>
            
              
              <a class="source" href="shape.html">
                shape.coffee
              </a>
            
              
              <a class="source" href="user.html">
                user.coffee
              </a>
            
              
              <a class="source" href="userSettings.html">
                userSettings.coffee
              </a>
            
              
              <a class="source" href="variable.html">
                variable.coffee
              </a>
            
              
              <a class="source" href="routes.html">
                routes.coffee
              </a>
            
              
              <a class="source" href="settings.html">
                settings.coffee
              </a>
            
              
              <a class="source" href="sockets.html">
                sockets.coffee
              </a>
            
              
              <a class="source" href="tutorial.html">
                tutorial.coffee
              </a>
            
              
              <a class="source" href="vectors.html">
                vectors.coffee
              </a>
            
              
              <a class="source" href="adminView.html">
                adminView.coffee
              </a>
            
              
              <a class="source" href="alertView.html">
                alertView.coffee
              </a>
            
              
              <a class="source" href="auditDataManagerView.html">
                auditDataManagerView.coffee
              </a>
            
              
              <a class="source" href="auditEventManagerView.html">
                auditEventManagerView.coffee
              </a>
            
              
              <a class="source" href="baseView.html">
                baseView.coffee
              </a>
            
              
              <a class="source" href="createMapView.html">
                createMapView.coffee
              </a>
            
              
              <a class="source" href="entityManagerView.html">
                entityManagerView.coffee
              </a>
            
              
              <a class="source" href="footerView.html">
                footerView.coffee
              </a>
            
              
              <a class="source" href="helpView.html">
                helpView.coffee
              </a>
            
              
              <a class="source" href="entitiesTabView.html">
                entitiesTabView.coffee
              </a>
            
              
              <a class="source" href="inspectorTabView.html">
                inspectorTabView.coffee
              </a>
            
              
              <a class="source" href="mapTabView.html">
                mapTabView.coffee
              </a>
            
              
              <a class="source" href="shapeTabView.html">
                shapeTabView.coffee
              </a>
            
              
              <a class="source" href="controlsView.html">
                controlsView.coffee
              </a>
            
              
              <a class="source" href="labelEditView.html">
                labelEditView.coffee
              </a>
            
              
              <a class="source" href="linkCreatorView.html">
                linkCreatorView.coffee
              </a>
            
              
              <a class="source" href="linkLabelsView.html">
                linkLabelsView.coffee
              </a>
            
              
              <a class="source" href="linkView.html">
                linkView.coffee
              </a>
            
              
              <a class="source" href="shapeLabelsView.html">
                shapeLabelsView.coffee
              </a>
            
              
              <a class="source" href="shapeView.html">
                shapeView.coffee
              </a>
            
              
              <a class="source" href="shapesMoverView.html">
                shapesMoverView.coffee
              </a>
            
              
              <a class="source" href="mapView.html">
                mapView.coffee
              </a>
            
              
              <a class="source" href="menuView.html">
                menuView.coffee
              </a>
            
              
              <a class="source" href="overlayView.html">
                overlayView.coffee
              </a>
            
              
              <a class="source" href="scriptEditorView.html">
                scriptEditorView.coffee
              </a>
            
              
              <a class="source" href="selfTestView.html">
                selfTestView.coffee
              </a>
            
              
              <a class="source" href="settingsView.html">
                settingsView.coffee
              </a>
            
              
              <a class="source" href="startView.html">
                startView.coffee
              </a>
            
              
              <a class="source" href="variableManagerView.html">
                variableManagerView.coffee
              </a>
            
          </div>
        </li>
      </ul>
    
    <ul class="sections">
        
          <li id="title">
              <div class="annotation">
                  <h1>routes.coffee</h1>
              </div>
          </li>
        
        
        
        <li id="section-1">
            <div class="annotation">
              
              <div class="pilwrap for-h2">
                <a class="pilcrow" href="#section-1">&#182;</a>
              </div>
              <h2>System ROUTES</h2>

            </div>
            
        </li>
        
        
        <li id="section-2">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-2">&#182;</a>
              </div>
              <p>Handle deep linking using the hashtag.
Implemented using the Backbone Router.</p>

            </div>
            
            <div class="content"><div class='highlight'><pre><span class="class"><span class="keyword">class</span> <span class="title">SystemApp</span>.<span class="title">Routes</span> <span class="keyword">extends</span> <span class="title">Backbone</span>.<span class="title">Router</span></span>

    routes:
        <span class="string">""</span>: <span class="string">"openDefault"</span>                   <span class="comment"># the default route will change the view based on the last view state</span>
        <span class="string">"map/:id"</span>: <span class="string">"openMap"</span>                <span class="comment"># open a map on the [Map View](mapView.html)</span>
        <span class="string">"auditdata"</span>: <span class="string">"openAuditData"</span>        <span class="comment"># open the [Audit Data Manager](auditDataManagerView.html) overlay</span>
        <span class="string">"auditevents"</span>: <span class="string">"openAuditEvents"</span>    <span class="comment"># open the [Audit Event Manager](auditEventManagerView.html) overlay</span>
        <span class="string">"createmap"</span>: <span class="string">"openCreateMap"</span>        <span class="comment"># open the [Create Map](createMapView.html) overlay</span>
        <span class="string">"entities"</span>: <span class="string">"openEntities"</span>          <span class="comment"># open the [Entity Manager](entityManagerView.html) overlay</span>
        <span class="string">"help"</span>: <span class="string">"openHelp"</span>                  <span class="comment"># open the [Help](helpView.html) overlay</span>
        <span class="string">"maps"</span>: <span class="string">"openStart"</span>                 <span class="comment"># open the [Start](startView.html) overlay</span>
        <span class="string">"settings"</span>: <span class="string">"openSettings"</span>          <span class="comment"># open the [Settings](settingsView.html) overlay</span>
        <span class="string">"start"</span>: <span class="string">"openStart"</span>                <span class="comment"># open the [Start](startView.html) overlay</span>
        <span class="string">"variables"</span>: <span class="string">"openVariables"</span>        <span class="comment"># open the [Variables Manager](variableManagerView.html) overlay</span></pre></div></div>
            
        </li>
        
        
        <li id="section-3">
            <div class="annotation">
              
              <div class="pilwrap for-h2">
                <a class="pilcrow" href="#section-3">&#182;</a>
              </div>
              <h2>ROUTER METHODS</h2>

            </div>
            
        </li>
        
        
        <li id="section-4">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-4">&#182;</a>
              </div>
              <p>The default route &quot;/&quot; will check if there&#39;s a map open. If there&#39;s none,
then open the <a href="startView.html">start view</a>.</p>

            </div>
            
            <div class="content"><div class='highlight'><pre>    openDefault: =&gt;
        <span class="keyword">if</span> SystemApp.mapView.model?
            <span class="property">@showOverlay</span> <span class="literal">false</span>
        <span class="keyword">else</span>
            <span class="property">@openStart</span>()</pre></div></div>
            
        </li>
        
        
        <li id="section-5">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-5">&#182;</a>
              </div>
              <p>Show the specified map on the <a href="mapView.html">Map View</a>.
If the map is invalid, then show a <a href="alertView.html">Footer Alert</a>.</p>

            </div>
            
            <div class="content"><div class='highlight'><pre>    openMap: (id) =&gt;
        SystemApp.consoleLog <span class="string">"ROUTE"</span>, <span class="string">"openMap"</span>, id

        SystemApp.auditDataManagerView.hide()
        SystemApp.settingsView.hide()
        SystemApp.startView.hide()
        SystemApp.helpView.hide()</pre></div></div>
            
        </li>
        
        
        <li id="section-6">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-6">&#182;</a>
              </div>
              <p>If no valid ID is specified, then clear the current map.</p>

            </div>
            
            <div class="content"><div class='highlight'><pre>        <span class="keyword">if</span> <span class="keyword">not</span> id? <span class="keyword">or</span> id <span class="keyword">is</span> <span class="number">0</span>
            SystemApp.mapView.bindMap <span class="literal">null</span>
            <span class="keyword">return</span></pre></div></div>
            
        </li>
        
        
        <li id="section-7">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-7">&#182;</a>
              </div>
              <p>Find map based on its friendly URL key. If no map is found, trying using the value as its ID.</p>

            </div>
            
            <div class="content"><div class='highlight'><pre>        map = _.find SystemApp.Data.maps.models, (item) -&gt; item.urlKey() <span class="keyword">is</span> SystemApp.DataUtil.getUrlKey id
        map = SystemApp.Data.maps.get(id) <span class="keyword">if</span> <span class="keyword">not</span> map?

        <span class="keyword">if</span> map?
            SystemApp.mapView.bindMap map
            SystemApp.menuEvents.trigger <span class="string">"active:map"</span>, map
            <span class="property">@showOverlay</span> <span class="literal">false</span>
        <span class="keyword">else</span>
            msg = SystemApp.Messages.errMapDoesNotExist
            SystemApp.alertEvents.trigger <span class="string">"footer"</span>, {isError: <span class="literal">true</span>, title: SystemApp.Messages.error, message: msg}
            <span class="property">@navigate</span> <span class="string">""</span>, {trigger: <span class="literal">false</span>}</pre></div></div>
            
        </li>
        
        
        <li id="section-8">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-8">&#182;</a>
              </div>
              <p>Show the <a href="auditDataManagerView.html">Audit Data Manager View</a>.</p>

            </div>
            
            <div class="content"><div class='highlight'><pre>    openAuditData: =&gt;
        SystemApp.consoleLog <span class="string">"ROUTE"</span>, <span class="string">"openAuditData"</span>
        <span class="property">@showOverlay</span> SystemApp.auditDataManagerView</pre></div></div>
            
        </li>
        
        
        <li id="section-9">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-9">&#182;</a>
              </div>
              <p>Show the <a href="auditDataManagerView.html">Audit Event Manager View</a>.</p>

            </div>
            
            <div class="content"><div class='highlight'><pre>    openAuditEvents: =&gt;
        SystemApp.consoleLog <span class="string">"ROUTE"</span>, <span class="string">"openAuditEvents"</span>
        <span class="property">@showOverlay</span> SystemApp.auditEventManagerView</pre></div></div>
            
        </li>
        
        
        <li id="section-10">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-10">&#182;</a>
              </div>
              <p>Show the <a href="createMapView.html">Create Map View</a>.</p>

            </div>
            
            <div class="content"><div class='highlight'><pre>    openCreateMap: =&gt;
        SystemApp.consoleLog <span class="string">"ROUTE"</span>, <span class="string">"openCreateMap"</span>
        <span class="property">@showOverlay</span> SystemApp.createMapView</pre></div></div>
            
        </li>
        
        
        <li id="section-11">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-11">&#182;</a>
              </div>
              <p>Show the <a href="entityManagerView.html">Entity Manager View</a>.</p>

            </div>
            
            <div class="content"><div class='highlight'><pre>    openEntities: =&gt;
        SystemApp.consoleLog <span class="string">"ROUTE"</span>, <span class="string">"openEntities"</span>
        <span class="property">@showOverlay</span> SystemApp.entityManagerView</pre></div></div>
            
        </li>
        
        
        <li id="section-12">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-12">&#182;</a>
              </div>
              <p>Show the <a href="helpView.html">Help View</a>.</p>

            </div>
            
            <div class="content"><div class='highlight'><pre>    openHelp: =&gt;
        SystemApp.consoleLog <span class="string">"ROUTE"</span>, <span class="string">"openHelp"</span>
        <span class="property">@showOverlay</span> SystemApp.helpView</pre></div></div>
            
        </li>
        
        
        <li id="section-13">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-13">&#182;</a>
              </div>
              <p>Show the <a href="settingsView.html">Settings View</a>.</p>

            </div>
            
            <div class="content"><div class='highlight'><pre>    openSettings: =&gt;
        SystemApp.consoleLog <span class="string">"ROUTE"</span>, <span class="string">"openSettings"</span>
        <span class="property">@showOverlay</span> SystemApp.settingsView</pre></div></div>
            
        </li>
        
        
        <li id="section-14">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-14">&#182;</a>
              </div>
              <p>Show the <a href="scriptEditorView.html">Script Editor View</a>.</p>

            </div>
            
            <div class="content"><div class='highlight'><pre>    openScriptEditor: (model, propertyName) =&gt;
        SystemApp.consoleLog <span class="string">"ROUTE"</span>, <span class="string">"openScriptEditor"</span>
        <span class="property">@showOverlay</span> SystemApp.scriptEditorView, model, propertyName</pre></div></div>
            
        </li>
        
        
        <li id="section-15">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-15">&#182;</a>
              </div>
              <p>Show the <a href="startView.html">Start View</a>.</p>

            </div>
            
            <div class="content"><div class='highlight'><pre>    openStart: =&gt;
        SystemApp.consoleLog <span class="string">"ROUTE"</span>, <span class="string">"openStart"</span>
        <span class="property">@showOverlay</span> SystemApp.startView</pre></div></div>
            
        </li>
        
        
        <li id="section-16">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-16">&#182;</a>
              </div>
              <p>Show the <a href="variableManagerView.html">Variables Manager View</a>.</p>

            </div>
            
            <div class="content"><div class='highlight'><pre>    openVariables: =&gt;
        SystemApp.consoleLog <span class="string">"ROUTE"</span>, <span class="string">"openVariables"</span>
        <span class="property">@showOverlay</span> SystemApp.variableManagerView</pre></div></div>
            
        </li>
        
        
        <li id="section-17">
            <div class="annotation">
              
              <div class="pilwrap for-h2">
                <a class="pilcrow" href="#section-17">&#182;</a>
              </div>
              <h2>HELPER METHODS</h2>

            </div>
            
        </li>
        
        
        <li id="section-18">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-18">&#182;</a>
              </div>
              <p>Hide all overlays (if there&#39;s any open) and show the specified view.
The new overlay can receive up to 2 parameters.
TODO! Refactor and use events to properly hide the other overlays!</p>

            </div>
            
            <div class="content"><div class='highlight'><pre>    showOverlay: (overlay, param1, param2) =&gt;
        <span class="keyword">for</span> view <span class="keyword">in</span> [
            SystemApp.auditDataManagerView,
            SystemApp.auditEventManagerView,
            SystemApp.createMapView,
            SystemApp.entityManagerView,
            SystemApp.helpView,
            SystemApp.settingsView,
            SystemApp.scriptEditorView,
            SystemApp.startView,
            SystemApp.variableManagerView]
            view.hide() <span class="keyword">if</span> overlay <span class="keyword">isnt</span> view

        <span class="keyword">if</span> overlay <span class="keyword">isnt</span> <span class="literal">false</span>
            SystemApp.toggleLoading <span class="literal">false</span>
            overlay.show param1, param2</pre></div></div>
            
        </li>
        
        
        <li id="section-19">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-19">&#182;</a>
              </div>
              <p>Refresh the current view if it&#39;s specified on the event, or the whole
page if view is left unspecified.</p>

            </div>
            
            <div class="content"><div class='highlight'><pre>    refresh: =&gt;
        SystemApp.consoleLog <span class="string">"ROUTE"</span>, <span class="string">"Refresh current page"</span>
        window.document.location.href = window.location.href</pre></div></div>
            
        </li>
        
    </ul>
  </div>
</body>
</html>
